package com.ycj.entropy.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;

import com.ycj.entropy.CreateStudyActivity;
import com.ycj.entropy.R;

public class HomeFragment extends Fragment {

    private View root;
    private View btnCreateStudy;
    private View btnHistory;
    private View btnAbout;


    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {

        this.root = inflater.inflate(R.layout.fragment_home, container, false);
        init();
        return root;
    }

    private void init() {
        this.btnCreateStudy = root.findViewById(R.id.create_study);
        this.btnHistory = root.findViewById(R.id.btn_history);
        this.btnAbout = root.findViewById(R.id.btn_about);

        this.btnCreateStudy.setOnClickListener(v -> startActivity(new Intent(getActivity(), CreateStudyActivity.class)));
        this.btnHistory.setOnClickListener(v -> Navigation.findNavController(getActivity(), R.id.nav_host_fragment).navigate(R.id.navigation_list));
        this.btnAbout.setOnClickListener(v-> Toast.makeText(getActivity(),"这是课程设计，哈哈哈哈",Toast.LENGTH_LONG).show());
    }


}